﻿using Sidvall.Serialization;

namespace Sidvall.Net
{
    public class AuthenticationHeader
    {
        #region Public Members

        public string Scheme { get; set; }
        public string Parameter { get; set; }

        #region Copy

        public AuthenticationHeader Copy()
        {
            var item = new AuthenticationHeader()
            {
                Parameter = this.Parameter,
                Scheme = this.Scheme,
            };
            return item;
        }

        #endregion
        #region IsEqual

        public bool IsEqual(AuthenticationHeader obj)
        {
            return IsEqual(this, obj);
        }

        #endregion
        #region IsEqual - Static

        public static bool IsEqual(AuthenticationHeader item1, AuthenticationHeader item2)
        {
            if (item1 == null)
            {
                if (item2 == null)
                    return true;
                else
                    return false;
            }
            else if (item2 == null)
                return false;
            if (!item1.Scheme.Equals(item2.Scheme, true, System.StringComparison.OrdinalIgnoreCase))
                return false;
            if (!item1.Parameter.Equals(item2.Parameter, true, System.StringComparison.OrdinalIgnoreCase))
                return false;
            return true;
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return this.Scheme.Append(this.Parameter, " ");
        }

        #endregion

        #endregion
    }
}
